﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace AmorCanino.Web.Models.Authentication
{
    public class User : IPrincipal
    {
        public int id { get; set; }

        public string Name { get; set; }

        public string Email { get; set; }

        public string Privileges { get; set; }

        public bool Visible { get; set; }

        public int UnreadedMessages { get; set; }

        public IIdentity Identity
        {
            get
            {
                return new GenericIdentity(this.Name);
            }
        }

        public bool IsInRole(string role)
        {
            var roles = this.Privileges.ToUpperInvariant().Split(new[] {','});
            return roles.Contains(role.ToUpper());
        }
    }
}